package com.weijian.demo1.mapper;

import com.weijian.demo1.entity.TeamMember;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface TeamMemberMapper {

    @Insert("INSERT INTO team_members (team_id, user_id, role, joined_at) " +
            "VALUES (#{teamId}, #{userId}, #{role}, #{joinedAt})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(TeamMember member);

    @Select("SELECT COUNT(*) > 0 FROM team_members WHERE team_id = #{teamId} AND user_id = #{userId}")
    boolean existsByTeamIdAndUserId(Long teamId, Long userId);
}